<?php

namespace Trawind\Remotes\Repositories\Account\Account;

use Trawind\Remotes\BaseRepository;
use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\Contracts\Repositories\Account\Account\ContactRepository;

/**
 * Class ContactRepositoryEloquent.
 *
 * @package namespace Trawind\Remotes\Repositories\Organization;
 */
class ContactRepositoryEloquent extends BaseRepository implements ContactRepository
{

    public $baseRoute='/organization/contacts';

    /**
     * ContactRepositoryEloquent constructor.
     */
    public function __construct()
    {
        $this->domain = ServiceDomain::ACCOUNT_DOMAIN();
    }


    /**
     * Retrieve all data of repository
     *
     * @param array $columns
     *
     * @return mixed
     */
    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }



    /**
     * Find data by id
     *
     * @param       $id
     * @param array $columns
     *
     * @return mixed
     */
    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
    }


    /**
     * Save a new entity in repository
     *
     * @param array $params
     * @return mixed
     */
    public function create(array $params)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => ['contacts' => $params]])
            ->result('POST');
    }



    /**
     * Update a entity in repository by id
     *
     * @param array $attributes
     * @param       $id
     *
     * @return mixed
     */
    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }

    /**
     * @inheritDoc
     */
    public function saveContacts(array $params)
    {
        // TODO: Implement saveContacts() method.
    }
}
